package com.syl.upimg.service.impl;

import com.syl.upimg.bean.BaseBean;
import com.syl.upimg.service.BaseUpload;
import com.syl.upimg.utils.ImageUtils;
import com.syl.upimg.utils.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * 58同城羊毛 没调通
 *
 * @author syl
 * @create 2020-04-02 16:43
 **/
@Service
@Deprecated
public class Tc58Fleece implements BaseUpload {
    @Autowired
    private RestTemplate restTemplate;

    @Override
    public RestTemplate createRestTemplate() {
        return restTemplate;
    }

    @Override
    public LinkedMultiValueMap<String, Object> getParam(FileSystemResource file, String fileName, String fileType) {
        return null;
    }

    @Override
    public String getJson(String filePath) {
        Map<String, String> map = new HashMap<>();
        map.put("Pic-Size", "0*0");
        map.put("Pic-Encoding", "base64");
        map.put("Pic-Path", "/nowater/webim/big/");
        map.put("Pic-Data", ImageUtils.imageToBase64(filePath));
        return JsonUtils.toJson(map);
    }

    public BaseBean upload(String filePath) throws IOException {
        return null;
    }

    @Override
    public MediaType getMediaType() {
        return MediaType.APPLICATION_JSON_UTF8;
    }

    @Override
    public HttpHeaders getDefaultHeader() {
        return this.getDefaultHeader("https://ai.58.com", "https://ai.58.com/pc/");
    }

    @Override
    public String[] getLimit() {
        return new String[]{"jpg", "png", "bmp"};
    }

    @Override
    public String getUrl() {
        return "https://upload.58cdn.com.cn/json";
    }

}
